<?php
/**
 * Klasa walidująca dane.
 * @author Mateusz Łędzewicz
 * @author Patryk Powiłan
 */
class Validator{
	//-------------------BASE VALIDATION-------------------------------
	public static function checkInt($value){
		if(is_bool($value))
			return false;
		return (bool)preg_match('/^[-+]?((\d+)(\.)?([0])?)$/', $value);
	}
	
	public static function checkFloat($value){
		if(is_bool($value))
			return false;
		return (bool)preg_match('/^[-+]?(\d+)(\.)?(\d+)?$/', $value);
	}
	
	public static function checkUnsignedInt($value){
		if(is_bool($value))
			return false;
		return (bool)preg_match('/^[+]?((\d+)(\.|,)?([0])?)$/', $value);
	}
	
	public static function checkAlfa($value){
		if(is_bool($value))
			return false;
		return (bool) preg_match("/^([a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ])+$/", $value);
	}
	
	
	public static function checkAlfaNum($value){
		if(is_bool($value))
			return false;
		return (bool) preg_match("/^([a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ0-9])+$/", $value);
	}
	
	public static function checkEmpty($value){
		return ($value === '');
	}
	
	//------------------------EXTENDED VALIDATION-----------------------
	
	public static function checkEmail($value){
		
		
		return (bool)preg_match('/^[a-zA-Z0-9\.\-_]+\@[a-zA-Z0-9\.\-_]+\.[a-z]{2,4}$/D', $value);
	}
}